package cn.opopopo.design_pattern_learn.行为型.iterator;

public class IteratorPatternDemo {
    public static void main(String[] args) {
        BookShelf shelf = new BookShelf(5);
        shelf.addBook(new Book("Java编程思想"));
        shelf.addBook(new Book("设计模式"));
        shelf.addBook(new Book("重构"));

        // 使用自定义迭代器遍历
        Iterator<Book> iterator = shelf.createIterator();
        System.out.println("使用迭代器遍历书架：");
        while (iterator.hasNext()) {
            Book book = iterator.next();
            System.out.println("📖 " + book);
        }
    }
}